
import {lift} from "./util.js";
import {defineFocusNav} from "./focusNav.js";
import {defineRovingTabindexByFocus} from "./rovingTabindex.js";

/**
 * Implements WAI-ARIA Radio Group pattern: https://www.w3.org/TR/wai-aria-practices/#toolbar
 *
 * @param toolbar d3 selection of one or more toolbar containers
 */
export function defineToolbar(toolbar) {
    toolbar.each(lift(bar => {
        const elements = bar.selectAll("button, a");
        defineFocusNav(elements, {enableUpDown: true});
        defineRovingTabindexByFocus(elements);
    }));
}
